using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Web_ProductCompare : Shop, IRequiresSessionState
{
	protected UserControls_cmpy_Top top1;
	protected Literal ShowCompareProductLiteral;
	protected HiddenField P_ID;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	protected HtmlGenericControl html1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_PreInit(object sender, EventArgs e)
	{
		try
		{
		}
		catch (Exception ex)
		{
			base.WriteTemErrMsg(ex.Message.ToString());
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		string text = base.Request["cb_id"];
		if (text == "" || text == null)
		{
			base.Response.Write("请先选择比较的商品！");
			base.Response.End();
		}
		if (!base.IsPostBack)
		{
			this.ShowCompareProductLiteral.Text = this.ShowCompareProductTable();
		}
	}
	public string ShowCompareProductTable()
	{
		string text = base.Request["cb_id"];
		string result;
		if (text != "" && (Text.CheckNumList(text, ',') || Text.IsNumber(text)))
		{
			string text2 = "";
			string sql = "select F_ProductID from HLShop_MyFavourite where F_ID in (" + text + ")";
			DataTable dataTable = this.conn.GetDataTable(sql);
			for (int i = 0; i < dataTable.Rows.Count; i++)
			{
				text2 = text2 + dataTable.Rows[i]["F_ProductID"].ToString() + ",";
			}
			string a = text2.Substring(text2.Length - 1);
			if (a == ",")
			{
				text2 = text2.Substring(0, text2.Length - 1);
			}
			Shop_Product shop_Product = new Shop_Product(this.conn);
			DataTable compareProductsByPrdouctID_Array = shop_Product.GetCompareProductsByPrdouctID_Array(text2);
			if (compareProductsByPrdouctID_Array.Rows.Count > 0)
			{
				int count = compareProductsByPrdouctID_Array.Rows.Count;
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("<table cellspacing=\"0\" class=\"CompareTable\" summary=\"商品属性比较\">" + Environment.NewLine);
				stringBuilder.Append("<tr>" + Environment.NewLine);
				stringBuilder.Append(" <th scope=\"col\" width=\"100px\">&nbsp;</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<th scope=\"col\"><a href=\"Member/Index.aspx?mainurl=AddMyFav.aspx?tag=AddProFav&ProductID=" + compareProductsByPrdouctID_Array.Rows[i]["ProductID"].ToString() + "\" target=\"_blank\">收藏</a></th>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine);
				stringBuilder.Append("<tr class=\"gray\"><th  abbr=\"图片\" width=\"100px\">图片</th>");
				for (int i = 0; i < count; i++)
				{
					string text3 = compareProductsByPrdouctID_Array.Rows[i]["ProductSmallImageUrl"].ToString();
					if (string.IsNullOrEmpty(text3))
					{
						text3 = "images/nopicture.gif";
					}
					stringBuilder.Append(string.Concat(new string[]
					{
						"<td class=\"picName\"><a href=\"ShowProduct.aspx?ProductID=",
						compareProductsByPrdouctID_Array.Rows[i]["ProductID"].ToString(),
						"\" target=\"_blank\"><img style='width:110px;height:110px' src=\"",
						text3,
						"\" onerror=\"this.src='/Images/nopicture.gif'\" /></a></td>"
					}));
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"名称\" >名称</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append(string.Concat(new string[]
					{
						"<td class=\"picName\"><a href=\"ShowProduct.aspx?ProductID=",
						compareProductsByPrdouctID_Array.Rows[i]["ProductID"].ToString(),
						"\" target=\"_blank\">",
						compareProductsByPrdouctID_Array.Rows[i]["ProductName"].ToString(),
						"</a></td>"
					}));
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"出价\" >出价</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td ><input type=\"image\" src=\"Images/button_buynow_small.gif\"  onclick=\"doBid('" + compareProductsByPrdouctID_Array.Rows[i]["ProductID"].ToString() + "')\"/></td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"剩余时间\">剩余时间</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td ><script>showlefttime(" + compareProductsByPrdouctID_Array.Rows[i]["LeftTime"].ToString() + ")</script></td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"店长\">店长</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append(string.Concat(new string[]
					{
						"<td ><a href=\"../Store/ShopIndex.aspx?ShopID=",
						compareProductsByPrdouctID_Array.Rows[i]["ShopID"].ToString(),
						"&ColumnTag=ShopInfo\" target=\"_blank\">",
						compareProductsByPrdouctID_Array.Rows[i]["ShopOwnerName"].ToString(),
						"</a></td>"
					}));
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"信誉/评价\">信誉/评价</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td ><a><script  type=\"text/javascript\">displayStar(" + compareProductsByPrdouctID_Array.Rows[i]["SaleCrediet"].ToString() + ");</script></a></td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"出售方式\">出售方式</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append(string.Concat(new string[]
					{
						"<td >",
						compareProductsByPrdouctID_Array.Rows[i]["ProductType"].ToString(),
						"：<span>",
						compareProductsByPrdouctID_Array.Rows[i]["StandPrice"].ToString(),
						"</span>元</td>"
					}));
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"运费\">运费</th>");
				for (int i = 0; i < count; i++)
				{
					string text4 = "卖家承担运费";
					if (compareProductsByPrdouctID_Array.Rows[i]["DeliverPayType"].ToString() == "0")
					{
						text4 = "";
					}
					if (compareProductsByPrdouctID_Array.Rows[i]["DeliverCharge"].ToString().Contains("|"))
					{
						string[] array = compareProductsByPrdouctID_Array.Rows[i]["DeliverCharge"].ToString().Split(new char[]
						{
							'|'
						});
						string text5 = text4;
						text4 = string.Concat(new string[]
						{
							text5,
							"平邮：",
							array[0],
							"&nbsp;元<br>快递：",
							array[1],
							"&nbsp;元<br> EMS：",
							array[2],
							"&nbsp;元"
						});
					}
					stringBuilder.Append("<td >&nbsp;" + text4 + "</td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"所在地\">所在地</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td >" + compareProductsByPrdouctID_Array.Rows[i]["ProductPlace"].ToString() + "</td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"新旧程度\">新旧程度</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td >" + TextFormat.GetProductStandard(compareProductsByPrdouctID_Array.Rows[i]["ProductStandard"].ToString()) + "</td>");
				}
				stringBuilder.Append("</tr>" + Environment.NewLine + "<tr class=\"gray\"><th  abbr=\"支付方式\">支付方式</th>");
				for (int i = 0; i < count; i++)
				{
					stringBuilder.Append("<td>");
					string text6 = compareProductsByPrdouctID_Array.Rows[0]["Paytype"].ToString();
					Shop_PayType shop_PayType = new Shop_PayType();
					string[] array2 = text6.Split(new char[]
					{
						'|'
					});
					for (int j = 0; j < array2.Length; j++)
					{
						if (!string.IsNullOrEmpty(array2[j]))
						{
							DataTable payTypeByTypeIDUserIDNotDisabled = shop_PayType.GetPayTypeByTypeIDUserIDNotDisabled(int.Parse(array2[j]), Convert.ToInt32(compareProductsByPrdouctID_Array.Rows[i]["SalerID"]));
							if (payTypeByTypeIDUserIDNotDisabled.Rows.Count > 0)
							{
								for (int k = 0; k < payTypeByTypeIDUserIDNotDisabled.Rows.Count; k++)
								{
									stringBuilder.Append(string.Concat(new string[]
									{
										"<a href=\"#\" title=\"",
										payTypeByTypeIDUserIDNotDisabled.Rows[k]["Intro"].ToString(),
										"\">",
										payTypeByTypeIDUserIDNotDisabled.Rows[k]["TypeName"].ToString(),
										"</a>&nbsp;/&nbsp;"
									}));
								}
							}
							payTypeByTypeIDUserIDNotDisabled.Dispose();
						}
					}
					stringBuilder.Append("&nbsp;</td>");
				}
				stringBuilder.Append("</table>" + Environment.NewLine);
				result = stringBuilder.ToString();
				return result;
			}
		}
		result = "无比较商品";
		return result;
	}
}
